#include<bits/stdc++.h>

using namespace std;
int n;
int a[100005];
vector<int> v[100005];

int main() {
    cin >> n;
    for (int i = 1; i <= n; i++)cin >> a[i], v[i].push_back(a[i]);
    string s;
    while (cin >> s) {
        if ( s == "CreatePlayer" ) {
            v[++n].push_back(0);
        }
        if ( s == "Update" ) {
            int id, money;
            cin >> id >> money;
            int p = v[id].back();
            v[id].pop_back();
            v[id].push_back(p + money);
        }
        if ( s == "Query" ) {
            int id;
            cin >> id;
            int pos = 1, temp = v[id][0];
            for (int i = 1; i <= n; i++) {
                if ( v[i][0] > temp ) {
                    pos++;
                }
            }
            cout << pos << endl;
        }
        if ( s == "Get" ) {
            int pos;
            cin >> pos;
            for (int i = 1; i <= n; i++) {
                int gt = 1, temp = v[i][0];
                for (int j = 1; i <= n; j++) {
                    if ( v[j][0] > temp )gt++;
                }
                if ( gt == pos ) {
                    cout << v[i][0] << endl;
                    break;
                }
            }
        }
    }
    return 0;
}